<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script src="__STATIC__/js/jquery.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <script src="__STATIC__/bootstrap-table/js/bootstrap-table.js"></script>
    <script src="__STATIC__/bootstrap-table/js/bootstrap-table-zh-CN.min.js"></script>
    <script src="__STATIC__/bootstrap-table/js/dropdown.js"></script>
    <link rel="stylesheet" href="__STATIC__/bootstrap-table/css/bootstrap-table.min.css">
    <link rel="stylesheet" href="__STATIC__/bootstrap-table/css/bootstrap.css">
    <script type="text/javascript" src="__STATIC__/x-admin/js/xadmin.js"></script>
    <link rel="stylesheet" href="__STATIC__/x-admin/css/font.css">
    <link rel="stylesheet" href="__STATIC__/x-admin/css/xadmin.css">
    <style>
        th.borderright {
            text-align: center;
        }
        th {
            text-align: center;
        }
    </style>
</head>
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="#">管理员列表</a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<!--<div class="layui-row">-->
    <!--<form class="layui-form layui-col-md12 x-so" onsubmit="return false">-->
        <!--<input class="layui-input" placeholder="开始日" name="start" id="start">-->
        <!--<input class="layui-input" placeholder="截止日" name="end" id="end">-->
        <!--<input type="text" name="username"  placeholder="备份名称" autocomplete="off" class="layui-input">-->
        <!--<button class="layui-btn"  id="search"><i class="layui-icon">&#xe615;</i></button>-->
    <!--</form>-->
<!--</div>-->
<xblock>
    <button class="layui-btn" id="backup"><i class="layui-icon"></i>备份</button>
</xblock>
<table class="table table-bordered" style="text-align: center">
    <tr style="text-align: center">
        <th align="center" valign="middle" >名称</th>
        <th align="center" valign="middle" >备份时间</th>
        <th align="center" valign="middle" >大小(MB)</th>
        <th align="center" valign="middle">操作</th>
    </tr>
    {foreach(files as $val)}
    <tr style="text-align: center">
        <td >{$val.list}</td>
        <td >{$val.time}</td>
        <td >{$val.size}</td>
        <td >
            <a href="#"><button type="button" class="btn btn-info btn-xs" onclick="download({$val.downloadName})">下载</button></a>&nbsp;&nbsp;
        </td>
    </tr>
    {/foreach}
</table>
</body>
<script>
    layui.use(['laydate','layer'], function(){
        var laydate = layui.laydate;
        layer = layui.layer;
        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });
</script>
<script>

    //下载操作
    function download(fileName){
        window.location.href = "{:url('/backups/downloadBackupsName')}?fileName="+fileName;
    }
    //备份
    $("#backup").click(function(){
        $.ajax({
            url:"{:url('/backups/backups_database')}",
            type:"post",
            dataType:"json",
            beforeSend:function() {
                index = top.layer.msg('生成中请稍后', {
                    icon: 16
                    ,shade: 0.01
                    ,time:1000000
                    ,type:2
                });
            },
            success:function(res){
                if(res.code){
                    top.layer.closeAll();
                    layer.msg(res.msg,{icon:1,time:2000},function(){
                        window.location.reload();
                    });
                    return;
                }else{
                    top.layer.closeAll();
                    layer.msg(res.msg,{icon:5,time:2000});
                    return;
                }
            }
        });
    });
</script>
</html>